/* 
 * File:   disjoint_sets.h
 * Author: aishwarya
 *
 * Created on March 20, 2011, 12:50 PM
 */

#ifndef DISJOINT_SETS_H
#define	DISJOINT_SETS_H

#ifdef	__cplusplus
extern "C" {
#endif

    typedef int Rank; /* Rank of each set */
    typedef int Parent; /* Representative element (parent) of each set */

    typedef struct _disjoint_sets {
        Parent *P;
        Rank *R;
        int nelements;
    } disjoint_sets;

    void set_init(disjoint_sets *s, int nelements) ;
    void set_make(disjoint_sets *s, int v) ;
    Parent set_find(disjoint_sets *s, int v) ;
    void set_union_p(disjoint_sets *s, Parent pu, Parent pv) ;
    void set_union_c(disjoint_sets *s, int u, int v) ;
    int set_is_same_component(disjoint_sets *s, int u, int v) ;
    void set_clean(disjoint_sets *s) ;

#ifdef	__cplusplus
}
#endif

#endif	/* DISJOINT_SETS_H */

